package com.fz.com.fz.dao;

import com.fz.entity.Student;
import com.fz.mapper.StudentMapper;
import com.fz.mybatis.MyBatisHelper;
import org.apache.ibatis.session.SqlSession;

import java.util.List;
import java.util.Map;

/**
 * Created by webrx on 2017-08-24.
 */
public class StudentDAO implements StudentMapper{
    private SqlSession session = new MyBatisHelper().getSession();
    private StudentMapper sdao;

    public StudentDAO(){
        this.sdao = session.getMapper(StudentMapper.class);
    }
    public List<Student> queryall() {
        return this.sdao.queryall();
    }

    public int deleteById(int id) {
        int num = 0;
        num = this.sdao.deleteById(id);
        this.session.commit();
        return num;
    }

    public List<Student> queryByName(String n) {
        return this.sdao.queryByName(n);
    }

    public int count() {
        return this.sdao.count();
    }

    public Map<String, Object> showById(int id) {
        return this.sdao.showById(id);
    }

    public List<Map<String, Object>> show() {
        return this.sdao.show();
    }

    public Student sById(int id) {
        return this.sdao.sById(id);
    }

    public int deleteAll() {
        int num = 0;
        num = this.sdao.deleteAll();
        this.session.commit();
        return num;
    }


    public int add(String name, int score, String address) {
        int num = 0;

        num = this.sdao.add(name,score,address);
        this.session.commit();
        return num;
    }
}
